home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1165 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.9 KB

  1. Path: nntp-server.caltech.edu!ansok
  2. From: ansok@alumnae.caltech.edu (Gary E. Ansok)
  3. Newsgroups: alt.msdos.programmer,comp.lang.c
  4. Subject: Re: Pascal program works but not C program!
  5. Date: 11 Jan 1996 20:36:31 GMT
  6. Organization: Caltech Alumni Association
  7. Message-ID: <4d3scf$4uk@gap.cco.caltech.edu>
  8. References: <4cdpr2$psi@lugb.latrobe.edu.au> <Pine.SV4.3.91-heb-2.04.960104114930.16292A-100000@cs.technion.ac.il> <4cp3vc$8nh@brahms.tfi.be> <4cpqt6$9r8@solutions.solon.com>
  9. NNTP-Posting-Host: alumnae.caltech.edu
  10.  
  11. In article <4cpqt6$9r8@solutions.solon.com>,
  12. Peter Seebach <seebs@solutions.solon.com> wrote:
  13. >ANSI/ISO C *requires* one of two declarations of main in a hosted environment.
  14. >(In a freestanding environment, it is implementation defined whether or not
  15. >there may be, must be, or is, a function named main.)  They both return int.
  16. >One has no arguments, the other has two.
  17.  
  18. Implementations are free to accept other declarations of main().  Indeed,
  19. the Rationale (not strictly part of the Standard, of course) says (p. 11)
  20. "While many implementations support more than two arguments to main, such
  21. practice is neither blessed nor forbidden by the Standard; a program that
  22. defines main with three arguments is not _strictly conforming_."
  23.  
  24. So your program is not erroneous if it expects three arguments to main(),
  25. as long as your compiler accepts it.  It just isn't necessarily portable
  26. to any other system (or compiler).
  27.  
  28. So if you find a compiler that won't accept "int main(int, char **)",
  29. you have grounds for a complaint.  If your compiler won't accept
  30. "void main(int, char **, char **)", tough.  You're SOL unless there
  31. is some other standard (like POSIX, perhaps) that requires it -- then
  32. your program is limited to systems covered by that other standard.
  33.  
  34. Yes, I think programmers should remove unnecessary non-portabilities
  35. from their code.  No, I don't think "void main()" should be the instant
  36. flame-trigger it seems to be.
  37.  
  38. Gary Ansok
  39. ansok@alumni.caltech.edu
  40.